The following gives a brief description of the supported C-calculator syntax and differences with standard C.
The following operators are recognized, in order of precedence:
++, -- (post and pre) increment-decrement -, ! unary minus and logical NOT ^ exponentiation, right associative /, *, % division, multiplication, modulo +, - addition, subtraction >, >=, <, <=, ==, != relational operators && logical AND || logical OR =, +=, -=, /=, *= assignments, right associative
All operators are left associatives except those specified. They are all common to C except for the exponentiation operator.
The following keywords are reserved tokens: auto, if, else, while, for, break, continue, and return, plus two extra keywords proc, func. They roughly obey the same syntax as in C so that statements like:
if (conditions)
cmode-line-statement
or
if (conditions) cmode-line-statement
or
if (conditions) {
cmode-statements
}
The same thing is true for the else constructions else of which some examples follow:
if (conditions)
cmode-line-statement
else
cmode-line-statement
or
if (conditions) {
cmode-statements
} else {
cmode-statements
}
Here cmode-line-statement means any semicolon separated list of C-calculator mode statements typed on the same line. Since semicolons are separators and not terminators, empty statements are defined by empty braces { }.
The return keyword must have parentheses when returning a value from a function as in return(x * sin(y)). A single return will only be recognized from within a procedure.
To avoid potential confusion with variables, keywords cannot be abbreviated.
As opposed to C, there exists no integer in the C-calculator mode. All scalar variables and numbers are double precision. This means that logical true is 1.0 and false is 0.0. As in C, one must be careful with comparison operators. The C switch syntax is not supported (would require integers).
As an extension, string comparison is possible with the equality operators `==' and `!='. This will return true or false if the string variables (or constants) are identical or not. Assignments of string variables actually copies all characters of the string on the RHS to the string variable on the LHS. String additions and subtractions are also possible.
Function and procedure definitions are defined with prototypes, i.e., a list of variables representing the proper kind of variable. At run-time, the arguments of the function are checked for type compatibility and for their number.
All variables are global except automatic variables defined using the auto keyword.
cmode, let, math, scan, strings, auto